package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(40)
public class JiuzhouqunjiangGameStrategy extends BaseGameStrategy {

    public static final String URL = "http://111.170.174.244:30288/gmss/user/gmquery.php";

    @GongnengMethod(1)
    public String pay(SendItem item) {
        System.out.println("发送充值：金额：");
        return "充值已发送，金额：";
    }

    /**
     * type: mail
     * uid: m666666
     * item: 88888888
     * num: 9999
     * qu: 10001
     * checknum: diyao88
     *
     * @param item
     * @return
     */
    @GongnengMethod(4001)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("checknum", "diyao88");
        params.add("type", "mail");
        params.add("qu", "10001");

        params.add("uid", item.uid);
        params.add("num", item.number);
        params.add("item", item.itemId);

        return RestTemplateUtil.sendPostForm(URL, params);
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.uid = "10000000001";
        item.number = "121";
        item.itemId = "1,19";
        System.out.println(new JiuzhouqunjiangGameStrategy().mail(item));
    }
}

